// 
// Created by admin on 2021/12/4.
//
#include <string>
#include <vector>
#include "S383.h"
using namespace std;

bool S383::canConstruct(const string& ransomNote, const string& magazine) {
    if (ransomNote.size() > magazine.size()) {
        return false;
    }
    vector<int> cnt(26);
    for (auto & c : magazine) {
        cnt[c - 'a']++;
    }
    for (auto & c : ransomNote) {
        cnt[c - 'a']--;
        if (cnt[c - 'a'] < 0) {
            return false;
        }
    }
    return true;
}